home *** CD-ROM | disk | FTP | other *** search
- /* Callbacks.c */
- /*
- * Callbacks.c
- * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
- *
- * This is a group of six functions with a common form. They are called by AOCE to
- * enumerate parts of the directory structure and, in turn, call back to functions
- * in this module. They have exactly the same format, except for differences in
- * the name of the variables and the type of the parameter. To emphasize the
- * parallel structure -- and, not least, to save typing time -- I generate five of
- * the six functions from a common macro definition. See the definition of
- * MyForEachAttrTypeLookup at the end to see how the macro expands.
- *
- * This code was written by a professional programmer with many years experience.
- * Don't try this at home.
- */
- #include "DTSSampleCSAM.h"
-
- /*
- * Name Function name MyForEachEnumSpec
- * Parm Function param type DirEnumSpec
- * func Callback function enumerateParsePB.eachEnumSpec
- */
- #define DIR (*((DirParamBlockPtr) userPB))
- #define Callback(Name, Parm, func) \
- pascal Boolean Name( \
- long userPB, \
- const Parm *parmPtr \
- ) \
- { \
- Boolean stopNow = FALSE; \
- long saveA5; \
- if (DIR.func != NULL) { \
- saveA5 = SetA5(DIR.header.saveA5); \
- stopNow = (DIR.func) \
- (DIR.header.clientData, parmPtr); \
- SetA5(saveA5); \
- } \
- return (stopNow); \
- }
-
- Callback(MyForEachEnumSpec,
- DirEnumSpec, enumerateParsePB.eachEnumSpec)
- Callback(MyForEachRecordID,
- RecordID, enumeratePseudonymParsePB.eachRecordID)
- Callback(MyForEachLookupRecordID,
- RecordID, lookupParsePB.eachRecordID)
- Callback(MyForEachAttrType,
- AttributeType, enumerateAttributeTypesParsePB.eachAttrType)
- Callback(MyForEachAttrValue,
- Attribute, lookupParsePB.eachAttrValue)
-
- /*
- * Always one guy what gotta be clever. MyForEachAttrTypeLookup
- * is just like the other callbacks except for the extra
- * parameter.
- */
- pascal Boolean
- MyForEachAttrTypeLookup(
- long userPB,
- const AttributeType *parmPtr,
- AccessMask myAttrAccMask
- )
- {
- Boolean stopNow = FALSE;
- long saveA5;
-
- if (DIR.lookupParsePB.eachAttrType != NULL) {
- saveA5 = SetA5(DIR.header.saveA5);
- stopNow = (DIR.lookupParsePB.eachAttrType)
- (DIR.header.clientData, parmPtr, myAttrAccMask);
- SetA5(saveA5);
- }
- return (stopNow);
- }
-